package com.addcn.fog.control {
	import com.addcn.fog.model.ModelLocator;
	import com.addcn.fog.model.IModelLocator;
	import com.addcn.fog.view.ViewLocator;
	import com.addcn.fog.view.IViewLocator;
	import com.addcn.fog.control.Controller;
	import com.addcn.fog.control.IController;
	import com.addcn.fog.control.SimpleCommand;
	/**
	 * 宏命令基类
	 * <p>
	 * <ul>
	 * <li>顺序执行多个command,每个执行都会创建一个command对象,并传递notification携带的参数</li>
	 * </ul>
	 * </p>
	 * 
	 */
	public class MacroCommand extends SimpleCommand implements ICommand {
		protected var m_subCommands:Array;
		
		public function MacroCommand() {
			m_subCommands = new Array();
			initialize();		
		}
		
		protected function initialize():void {
			//到子类将覆盖此函数
		}
		
		protected function addSubCommand(commandName:Class):void {
			m_subCommands.push(commandName);
		}
		
		final override public function execute(data:Object = null):void {
			while (m_subCommands.length > 0) {
				var commandClass:Class = m_subCommands.shift();
				var commandInstance:ICommand = new commandClass();
				commandInstance.execute(data);
			}
		}
	}
}
